import request from '@/core/interceptors'

export const getCategory = () => {
  return request({
    url: import.meta.env.VITE_MENU_PATH + `/category`,
    method: "get",
  });
};

/**
 *
 * @param {string} name 分类名称
 */
export const createCategory = (name) => {
  return request({
    url: import.meta.env.VITE_MENU_PATH + `/category`,
    method: "post",
    data: {name}
  });
};

/**
 *
 * @param {string} name 分类名称
 * @param {string} id 分类id
 */
export const updateCategory = (name, id) => {
  return request({
    url: import.meta.env.VITE_MENU_PATH + `/category`,
    method: "patch",
    data: {name, id}
  });
};

/**
 *
 * @param {string} id 分类id
 */
export const deleteCategory = (id) => {
  return request({
    url: import.meta.env.VITE_MENU_PATH + `/category`,
    method: "delete",
    data: {id}
  });
};